﻿<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('绑定园区角色')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-area-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">园所名称：</label>
                <input  type="hidden" name="areaId" id="areaId" th:value="${id}">
                <div class="col-sm-8">
                    <input  class="form-control" type="text" name="name" id="name" th:value="${name}" readonly>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">系统列表：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select id="platformId" name="platformId" class="form-control m-b" onchange="getRoleList()">-->
<!--                        <option value="">请选择</option>-->
<!--                        <option  th:each="platform : ${platforms}"  th:value="${platform.platformId}"  th:text="${platform.name}">上级集团</option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">角色列表：</label>
                <div class="col-sm-8">
                    <select id="roleId" name="roleId" class="form-control m-b" >
                        <option  th:each="role : ${roles}"  th:value="${role.roleId}"  th:text="${role.roleName}"></option>-->
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "sso/role"
        $("#form-area-add").validate({
            focusCleanup: true
        });

        var isClick = true;
        function submitHandler() {
            if ($.validate.form() && isClick) {
                isClick = false;
                $.operate.save(prefix + "/addAreaRole", $('#form-area-add').serialize());
            }
        }

        function getRoleList(){
            var platformId = $("#platformId").val();
            var areaId = $("#areaId").val();
            $("#roleId").html("");
            $.ajax({
                cache : true,
                type : "POST",
                url: "/sso/role/platformIdAndAreaIdZeroByRoleList",
                async : false,
                data : {
                    "platformId":platformId,
                    "areaId":areaId
                },
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    var str ="";
                    for (let i = 0; i < data.length; i++) {
                        str += '<option value="' + data[i].roleId + '">' + data[i].roleName + '</option>'
                        $("#roleId").html(str);
                    }
                }
            });
        }

    </script>
</body>
</html>